#include <bits/stdc++.h>
using namespace std;
int n,k;
const int N=1e5+50;
typedef long long ll;
ll a[N];
priority_queue<ll,vector<ll>,greater<ll> > q;
int main(void){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        q.push(a[i]);
    }
    ll sub=0;
    while(k>0){
        if(q.empty()){
            printf("0\n");
        }else{
            ll t=q.top();
            //printf("%lld %lld\n",t,sub);
            q.pop();
            while(t-sub==0 && !q.empty()){
                //printf("F\n");
                if(!q.empty()){
                    t=q.top();
                    //printf("t %lld\n",t);
                    q.pop();
                }
            }
            printf("%lld\n",t-sub);
            sub+=(t-sub);
        }
        k--;
    }
    return 0;
}